<template>
  <div class="nav">
    <div class="avabox">
      <a
        href="#"
        class="avatar"
      >
        <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" /></a>
    </div>
    <ul>
      <li>
        <RouterLink
          to="/home"
          id="parentIframe"
        >课程成绩</RouterLink>
      </li>
      <li>
        <RouterLink to="/about">个人成绩</RouterLink>
      </li>
      <li>
        <RouterLink to="/module">module</RouterLink>
      </li>

      <li>
        <div class="but">
          <RouterLink to="/login">退出</RouterLink>
        </div>
      </li>
    </ul>
  </div>
  <RouterView />
</template>
<script>
window.addEventListener("scroll", function () {
  //获取元素
  var header = document.querySelector("header"); //querySelector() 方法返回文档中匹配指定 CSS 选择器的一个元素。
  // 添加类
  header.classList.toggle("sticky", window.scrollY > 0);
});
setTimeout(function () {
  // IE
  if (document.all) {
    document.getElementById("parentIframe").click();
  }
  // 其它浏览器
  else {
    var e = document.createEvent("MouseEvents");
    e.initEvent("click", true, true);
    document.getElementById("parentIframe").dispatchEvent(e);
  }
}, 0);
</script>
<style scoped>
:root {
  --mhover: #542626da;
}

* {
  margin: 0;
  padding: 0;
}

a {
  text-decoration: none;
}
.nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 80px;
  box-shadow: 10px 0 10px #dfdfdfda;
  /* overflow: hidden; */
}
.avabox {
  width: 10%;
}
.nav ul {
  list-style: none;
  display: flex;
  width: 90%;
  height: 100%;
}

.nav ul li {
  flex: 1;
  float: left;
  line-height: 80px;
  text-align: center;
}
.nav ul li a {
  color: #542626da;
  font-size: 1rem;
  font-weight: 600;
}
.nav ul li a:hover {
  color: rgba(255, 104, 129, 0.904);
}
.avatar {
  float: left;
  text-align: right;
  width: 80%;
  height: 70px;
  line-height: 100px;
}
.avatar img {
  width: 100%;
}
@media (max-width: 500px) {
  .nav ul li {
    padding-left: 4px;
  }
  .nav ul li a {
    font-size: 0.9rem;
  }
  .avatar {
    padding-left: 8px;
    text-align: center;
  }
}
</style>
